package main;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

class SimulatorPanel extends JPanel implements MouseListener, KeyListener {

	public static SensorPanel sensorPanel;
	
    Simulator sim;
    JPanel infoPanel = new JPanel();

    // Control for button updates
    boolean running = false;

    SimulatorPanel() {
    	this.setFocusable(true);

    	sensorPanel = new SensorPanel();
    	    	
        sim = new Simulator();

        JPanel rightPanel = new JPanel();
        rightPanel.setSize(200, 600);
        rightPanel.setLayout(new BorderLayout());
        
        infoPanel.setSize(200, 400);
        infoPanel.setPreferredSize(new Dimension(200, 400));
        infoPanel.add(new JLabel("INFO"));
        infoPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
        
        // Layout the sensor panel horizontally     
        
        rightPanel.add(infoPanel, BorderLayout.NORTH);
        rightPanel.add(sensorPanel, BorderLayout.SOUTH);
        
        // Layout outer panel
        setLayout(new BorderLayout());
        add(sim, BorderLayout.WEST);
        add(rightPanel, BorderLayout.EAST);
    }

	@Override
	public void mouseClicked(MouseEvent e) {
		UserInterface.setContentPane(UserInterface.sensorSelection);		
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyPressed(KeyEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyReleased(KeyEvent arg0) {
		if (arg0.getKeyCode() == arg0.VK_SPACE) {
			sim.setAnimation(!sim.timer.isRunning());
		}
		
	}

	@Override
	public void keyTyped(KeyEvent arg0) {
		// TODO Auto-generated method stub
		
	}

}